Skip to content

fix(worker): ignore Canceled unhandled rejections - #9

Merged
pi0 merged 2 commits into
pithings:mainfrom
kazablock:fix/worker-canceled-rejection
Nov 22, 2026
Merged

pi0 merged 2 commits into
pithings:mainfrom
kazablock:fix/worker-canceled-rejection

Conversation

@kazablock

Copy link
Copy Markdown
Contributor

VS Code promise-cancellation races surface as Canceled rejections (e.g. a pending ptyHost resolved-variables RPC cancelled on extension-host restart). Treating them as fatal crashed the worker on every restart, and the respawn loop re-triggered the same race. Canceled rejections (by name or message) are now logged and ignored; all others still forward { type: error } to the parent and exit 1, so the respawn contract is unchanged.

Adds lib/worker.test.ts: forks the actual worker.mjs against a stubbed dist entry in a temp dir and covers both Canceled shapes plus the forward-and-exit path end-to-end over IPC.

VS Code promise-cancellation races surface as Canceled rejections (e.g. a
pending ptyHost resolved-variables RPC cancelled on extension-host restart).
Treating them as fatal crashed the worker on every restart, and the respawn
loop re-triggered the same race. Canceled rejections (by name or message) are
now logged and ignored; all others still forward { type: error } to the
parent and exit 1, so the respawn contract is unchanged.

Adds lib/worker.test.ts: forks the actual worker.mjs against a stubbed dist
entry in a temp dir and covers both Canceled shapes plus the forward-and-exit
path end-to-end over IPC.
@kazablock

Copy link
Copy Markdown
Contributor Author

@pi0 can you pls look at this pr

- Restore README.md symlink target (a trailing newline broke it).
- Match VS Code's isCancellationError (Error with name AND message
  "Canceled") instead of name OR message.
- Apply the filter to uncaughtException too (--unhandled-rejections=strict).
- Log only the first ignored Canceled error, and none during shutdown.
- Give unhandled rejections a 1s grace period (cancelled on
  rejectionHandled) before treating them as fatal, like VS Code.
- Tests: register harness before awaiting ready, SIGKILL stragglers,
  poll instead of fixed sleeps, cover the new cases.
@pi0
pi0 merged commit d303a40 into pithings:main Nov 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants